package com.qvtu.springboot.mapper;

import com.qvtu.springboot.entity.Article;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ArticleMapper {

    @Insert("insert into `article` (title,img,description,content,time)"+
    "values (#{title},#{img},#{description},#{content},#{time})")
    void insert(Article aritcle);

    @Delete("delete from `article` where id=#{id}")
    void delete(Integer id);

    @Update("update `article` set title=#{title}, img=#{img}, description=#{description}, content=#{content}, time=#{time} " +
            "where id=#{id}")
    void update(Article article);

    @Select("select * from `article` where id=#{id}")
    Article selectById(Integer id);

    List<Article> selectAll(Article article);

    @Select("select count(*) from `article` where time like '%${date}%'")
    Integer selectCountByDate(String date);
}
